package com.single;

/**
 * @author cyf
 * @description 单例模式
 * @create 2018-09-20 17:54
 **/
public class SingleTon1 {


    /**
     *  饿汉模式 ：线程安全，丢失延迟实例化节约资源的好处
     */

    private static SingleTon1 instance = new SingleTon1();

    private SingleTon1() {
    }

    public static SingleTon1 getInstance() {
        return instance;
    }

    public static void main(String[] args) {
        SingleTon1 instance = SingleTon1.getInstance();
        SingleTon1 instance1 = SingleTon1.getInstance();
        System.out.println(instance == instance1);
    }

}
